package com.cskaoyan.service;

import com.cskaoyan.mapper.MarketOrderGoodsMapper;
import com.cskaoyan.mapper.MarketOrderMapper;
import com.cskaoyan.mapper.MarketUserMapper;
import com.cskaoyan.util.MyBatisUtil;
import com.cskaoyan.util.TransactionUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;
import java.util.Map;

public class AdminStatServiceImpl implements AdminStatService {

    @Override
    public List <Map> getAllOrderStat() {
        TransactionUtil.startTransaction();
        SqlSession sqlSession = TransactionUtil.getSqlSession();
        MarketOrderMapper orderMapper = sqlSession.getMapper(MarketOrderMapper.class);
        List <Map> maps = orderMapper.countOrderNum();

        TransactionUtil.commit();
        return  maps;



    }

    @Override
    public List <Map> getAllOrderGoodsStat() {
        TransactionUtil.startTransaction();
        SqlSession sqlSession = TransactionUtil.getSqlSession();

        MarketOrderGoodsMapper mapper = sqlSession.getMapper(MarketOrderGoodsMapper.class);

        List <Map> maps = mapper.countOrderGoodsNum();
        TransactionUtil.commit();
        return maps;



    }

    @Override
    public List <Map> getGroupUserByTime() {
        TransactionUtil.startTransaction();
        SqlSession sqlSession = TransactionUtil.getSqlSession();

        MarketUserMapper mapper = sqlSession.getMapper(MarketUserMapper.class);
        List <Map> maps = mapper.groupUserByDate();
        TransactionUtil.commit();
        return maps;



    }
}
